<template>
    <div>
        <div class="footer" >
            <section class="pagination"  v-if="total >= 1">
                <el-pagination
                background 
                @size-change="handleSizeChange(initSize)"
                @current-change="handlePageChange(initpage)"
                :current-page.sync="initpage"
                :page-sizes="[10, 30, 50, 100, 200]"
                :page-size.sync="initSize"
                :pager-count="initPagerCount"
                :layout="initLayout"
                :total="total">
                </el-pagination>
            </section>
        </div>
    </div>
</template>
<script>
    export default {
        props: ['total','page','size','id','pagerCount','layout'],
        data() {
            return {
                initpage: this.page || 1,
                initSize: this.size || 10,
                initPagerCount: this.pagerCount || 7,
                initLayout:this.layout || 'total, sizes, prev, pager, next, jumper'
            }
        },
        mounted() {
        
        },
        methods: {
            handlePageChange(page) {
                this.initpage = page
                if(this.id){
                    this.$emit('handlepagechange', {id:this.id,page:page})
                }else{
                    this.$emit('handlepagechange', page)
                }
            },
            handleSizeChange(size) {
                this.initSize = size
                if(this.id){
                    this.$emit('handleSizeChange', {id:this.id,size:size})
                }else{
                   this.$emit('handleSizeChange', size)
                }
                
            },
        }
    }
</script>